//
//  CommendTableViewController.m
//  GoodWayClient
//
//  Created by HuiDong on 15/12/3.
//  Copyright © 2015年 HuiDong. All rights reserved.
//

#import "CommendTableViewController.h"
#import "CommendTableViewCell.h"
#import "ShowMore.h"

@interface CommendTableViewController ()

@property (nonatomic, strong)NSArray *array;
@property (nonatomic, strong)NSMutableArray *arrayAll;

@end

@implementation CommendTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //footView的加载更多的显示
    ShowMore *showMore = [ShowMore footView];
    
    __weak CommendTableViewController *tempController = self;
    
    ShowMoreBlock block = ^{
        [tempController.arrayAll addObjectsFromArray:tempController.array];
        [tempController.tableView reloadData];
    };
    
    showMore.block = block;
    self.tableView.tableFooterView = showMore;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
//懒加载
- (NSArray *)array
{
    if (!_array) {
        _array = @[@{@"reason":@"推荐蓝天使者",@"achieve":@"获得1000元和1000积分",@"time":@"2015.11.27"},@{@"reason":@"推荐蓝天使者",@"achieve":@"获得1000元和1000积分",@"time":@"2015.11.27"},@{@"reason":@"推荐蓝天使者",@"achieve":@"获得1000元和1000积分",@"time":@"2015.11.27"},@{@"reason":@"推荐蓝天使者",@"achieve":@"获得1000元和1000积分",@"time":@"2015.11.27"},@{@"reason":@"推荐蓝天使者",@"achieve":@"获得1000元和1000积分",@"time":@"2015.11.27"},@{@"reason":@"推荐蓝天使者",@"achieve":@"获得1000元和1000积分",@"time":@"2015.11.27"},@{@"reason":@"推荐蓝天使者",@"achieve":@"获得1000元和1000积分",@"time":@"2015.11.27"}];
    }
    return _array;
}

- (NSMutableArray *)arrayAll
{
    if (!_arrayAll) {
        _arrayAll = [NSMutableArray arrayWithArray:self.array];
    }
    return _arrayAll;
}

//数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.arrayAll.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    CommendTableViewCell *cell = [CommendTableViewCell CommendWithTableView:tableView];
    cell.dic = self.arrayAll[indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

//行高
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 80;
}

//隐藏状态栏
-(UIStatusBarStyle)preferredStatusBarStyle
{
    return YES;
}

@end
